class: center, middle, inverse, title-slide # Módulo de Gráficos y Visualización de datos --- # Repasando <br> - Empezamos a ver los fundamentos del lenguaje R. <br> - Incorporamos la forma de trabajo a través de objetos. <br> - Empezamos a importar bases de datos, a procesar la información que hay dentro de ellas <br> - Conocimos algunas funciones para transformar sus elementos (variables, categorías, filas, columnas) --- class: middle, center, inverse # Visualización de datos - Paquete ggplot2 --- ### ¿Por qué visualizar? <br> - _"La visualización es el proceso de hacer visibles los contrastes, ritmos y eventos que los datos expresan, que no podemos percibir cuando vienen en forma de áridas listas de números y categorías."_ [^1] <br> - Interpretar / decodificar la información de forma visual <br> [^1]: https://bitsandbricks.github.io/ciencia_de_datos_gente_sociable/visualizacion.html --- ### El paquete ggplot2 <br> -- - _ggplot2_ es uno de los paquetes principales de _tidyverse_ <br> -- - Tiene la misma lógica de "capas" y de apilamiento de sentencias, como venimos haciendo con el comando __%>%__, pero ahora lo haremos con el símbolo __+__ -- - Necesitamos estructurar los datos de forma "vertical" (¿gather suena familiar?), es decir, una columna por cada dimensión (variable) y una fila por cada observación. Estructurar bien los datos ahorra muchos dolores de cabeza. --- ### Manos a la obra <br> Queremos analizar de forma descriptiva una o más variables. Intentemos con las herramientas que aprendimos hasta el momento. <br> -- Si queremos, por ejemplo, ver cómo se comporta el ingreso de la población, podemos empezar con el __ingreso de la ocupación princial__ de los individuos. Busquemos la variable en el diseño de registro: <img src="data:image/png;base64,#img/dis_reg_p21.png" width="80%" style="display: block; margin: auto;" /> --- ### Librerías <br> * Cargamos las librerías necesarias ```r library(tidyverse) library(questionr) library(eph) ``` <br> * Descargamos la base de datos con la función del paquete _eph_ para bajar los microdatos ```r base <- eph::get_microdata(2019, 4) %>% select(ESTADO, NIVEL_ED, CH04, PONDERA, P21, TOT_P12, PONDIIO) ``` --- ## El primer paso antes de hacer un gráfico es saber qué quiero mostrar y con qué tipo de datos cuento -- ### Analicemos la variable: -- ```r class(base$P21) ``` ``` [1] "integer" ``` -- ```r any(is.na(base$P21)) ``` ``` [1] FALSE ``` -- ```r summary(base$P21) ``` ``` Min. 1st Qu. Median Mean 3rd Qu. Max. -9 0 0 3399 4000 60000 ``` --- ## Ahora sí, intentemos graficarlo --- class: split-40 count: false .column[.content[ ```r *ggplot(data = base) ``` ]] .column[.content[ <img src="data:image/png;base64,#Modulo_3_Presentacion_files/figure-html/output_g1_1-1.png" width="100%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = base) + * aes(x = P21, * weights = PONDIIO) ``` ]] .column[.content[ <img src="data:image/png;base64,#Modulo_3_Presentacion_files/figure-html/output_g1_3-1.png" width="100%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = base) + aes(x = P21, weights = PONDIIO) + * geom_histogram() ``` ]] .column[.content[ <img src="data:image/png;base64,#Modulo_3_Presentacion_files/figure-html/output_g1_4-1.png" width="100%" /> ]] --- ### Saquemos aquellos valores extremos, para poder analizar mejor la distribución. <br> ```r base <- base %>% filter(P21 > 0 & P21 < 200000) ``` -- <br> Tiramos el summary nuevamente ```r summary(base$P21) ``` ``` Min. 1st Qu. Median Mean 3rd Qu. Max. 400 5000 9000 10827 15000 60000 ``` --- class: split-40 count: false .column[.content[ ```r *ggplot(data = base) ``` ]] .column[.content[ <img src="data:image/png;base64,#Modulo_3_Presentacion_files/figure-html/output_g2_1-1.png" width="100%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = base) + * aes(x = P21, * weights = PONDIIO) ``` ]] .column[.content[ <img src="data:image/png;base64,#Modulo_3_Presentacion_files/figure-html/output_g2_3-1.png" width="100%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = base) + aes(x = P21, weights = PONDIIO) + * geom_histogram(fill = "salmon", * color = "grey") ``` ]] .column[.content[ <img src="data:image/png;base64,#Modulo_3_Presentacion_files/figure-html/output_g2_5-1.png" width="100%" /> ]] --- ## Gráficos de Boxplot ### ¿Y si la distribución del ingreso se comporta de manera diferente en función de otra variable? - Probemos con otro tipo de gráfico que nos deje comparar, en este caso, para los distintos niveles educativos alcanzados En el diseño de registro esta variable la encontramos como __NIVEL_ED__ <img src="data:image/png;base64,#img/dis_reg_nivel_ed.png" width="80%" style="display: block; margin: auto;" /> --- class: split-40 count: false .column[.content[ ```r *ggplot(data = base) ``` ]] .column[.content[ <img src="data:image/png;base64,#Modulo_3_Presentacion_files/figure-html/output_boxplot_1-1.png" width="100%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = base) + * aes(x = NIVEL_ED) ``` ]] .column[.content[ <img src="data:image/png;base64,#Modulo_3_Presentacion_files/figure-html/output_boxplot_2-1.png" width="100%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = base) + aes(x = NIVEL_ED) + * aes(y = P21) ``` ]] .column[.content[ <img src="data:image/png;base64,#Modulo_3_Presentacion_files/figure-html/output_boxplot_3-1.png" width="100%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = base) + aes(x = NIVEL_ED) + aes(y = P21) + * geom_boxplot() ``` ]] .column[.content[ <img src="data:image/png;base64,#Modulo_3_Presentacion_files/figure-html/output_boxplot_4-1.png" width="100%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = base) + aes(x = NIVEL_ED) + aes(y = P21) + geom_boxplot() + * aes(group = NIVEL_ED) ``` ]] .column[.content[ <img src="data:image/png;base64,#Modulo_3_Presentacion_files/figure-html/output_boxplot_5-1.png" width="100%" /> ]] --- ## Mucho mejor! Pero... ¿Qué pasó con las categorías? ¿Cómo las muestro? -- - Tal como se descarga la base de la página del INDEC, vemos que la variable __NIVEL_ED__ es de tipo "entero". ```r class(base$NIVEL_ED) ``` ``` [1] "integer" ``` -- ```r table(base$NIVEL_ED) ``` ``` 1 2 3 4 5 6 7 25 90 119 184 85 122 3 ``` -- Transformemos, entonces, a _NIVEL_ED_ en una variable de tipo _factor_, asi podremos contar con las etiquetas e, incluso, reordenar sus categorías de forma ordinal --- ```r base <- base %>% mutate(NIVEL_ED = factor(NIVEL_ED, levels = c(7,1:6), labels = c("Sin instruccion", "Primaria incompleta", "Primaria completa", "Secundaria incompleta", "Secundaria completa", "Sup. incompleto", "Sup. completo"))) ``` Tiramos una frecuencia para chequear el trabajo hecho ```r table(base$NIVEL_ED) ``` ``` 1 2 3 4 5 6 7 686 2812 3352 5874 2710 4417 61 ``` --- ## Gráficos de Boxplot ### Ahora sí, con etiquetas en la variable, sumemos otros parámetros del gráfico --- class: split-40 count: false .column[.content[ ```r *ggplot(data = base) ``` ]] .column[.content[ <img src="data:image/png;base64,#Modulo_3_Presentacion_files/figure-html/output_g3_1-1.png" width="100%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = base) + * aes(x = NIVEL_ED) ``` ]] .column[.content[ <img src="data:image/png;base64,#Modulo_3_Presentacion_files/figure-html/output_g3_2-1.png" width="100%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = base) + aes(x = NIVEL_ED) + * aes(y = P21) ``` ]] .column[.content[ <img src="data:image/png;base64,#Modulo_3_Presentacion_files/figure-html/output_g3_3-1.png" width="100%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = base) + aes(x = NIVEL_ED) + aes(y = P21) + * geom_boxplot() ``` ]] .column[.content[ <img src="data:image/png;base64,#Modulo_3_Presentacion_files/figure-html/output_g3_4-1.png" width="100%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = base) + aes(x = NIVEL_ED) + aes(y = P21) + geom_boxplot() + * aes(group = NIVEL_ED) ``` ]] .column[.content[ <img src="data:image/png;base64,#Modulo_3_Presentacion_files/figure-html/output_g3_5-1.png" width="100%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = base) + aes(x = NIVEL_ED) + aes(y = P21) + geom_boxplot() + aes(group = NIVEL_ED) + * aes(fill = NIVEL_ED) ``` ]] .column[.content[ <img src="data:image/png;base64,#Modulo_3_Presentacion_files/figure-html/output_g3_6-1.png" width="100%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = base) + aes(x = NIVEL_ED) + aes(y = P21) + geom_boxplot() + aes(group = NIVEL_ED) + aes(fill = NIVEL_ED) + * theme_minimal() ``` ]] .column[.content[ <img src="data:image/png;base64,#Modulo_3_Presentacion_files/figure-html/output_g3_7-1.png" width="100%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = base) + aes(x = NIVEL_ED) + aes(y = P21) + geom_boxplot() + aes(group = NIVEL_ED) + aes(fill = NIVEL_ED) + theme_minimal() + * labs(x = "Máximo nivel educativo alcanzado") ``` ]] .column[.content[ <img src="data:image/png;base64,#Modulo_3_Presentacion_files/figure-html/output_g3_8-1.png" width="100%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = base) + aes(x = NIVEL_ED) + aes(y = P21) + geom_boxplot() + aes(group = NIVEL_ED) + aes(fill = NIVEL_ED) + theme_minimal() + labs(x = "Máximo nivel educativo alcanzado") + * labs(y = "Ingreso de la ocupación principal") ``` ]] .column[.content[ <img src="data:image/png;base64,#Modulo_3_Presentacion_files/figure-html/output_g3_9-1.png" width="100%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = base) + aes(x = NIVEL_ED) + aes(y = P21) + geom_boxplot() + aes(group = NIVEL_ED) + aes(fill = NIVEL_ED) + theme_minimal() + labs(x = "Máximo nivel educativo alcanzado") + labs(y = "Ingreso de la ocupación principal") + * labs(title = "Boxplot del Ingreso de la Ocupación Principal por máximo nivel de estudios alcanzado") ``` ]] .column[.content[ <img src="data:image/png;base64,#Modulo_3_Presentacion_files/figure-html/output_g3_10-1.png" width="100%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = base) + aes(x = NIVEL_ED) + aes(y = P21) + geom_boxplot() + aes(group = NIVEL_ED) + aes(fill = NIVEL_ED) + theme_minimal() + labs(x = "Máximo nivel educativo alcanzado") + labs(y = "Ingreso de la ocupación principal") + labs(title = "Boxplot del Ingreso de la Ocupación Principal por máximo nivel de estudios alcanzado") + * labs(caption = "Fuente: Elaboración propia en base a EPH-INDEC") ``` ]] .column[.content[ <img src="data:image/png;base64,#Modulo_3_Presentacion_files/figure-html/output_g3_11-1.png" width="100%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = base) + aes(x = NIVEL_ED) + aes(y = P21) + geom_boxplot() + aes(group = NIVEL_ED) + aes(fill = NIVEL_ED) + theme_minimal() + labs(x = "Máximo nivel educativo alcanzado") + labs(y = "Ingreso de la ocupación principal") + labs(title = "Boxplot del Ingreso de la Ocupación Principal por máximo nivel de estudios alcanzado") + labs(caption = "Fuente: Elaboración propia en base a EPH-INDEC") + * scale_y_continuous(limits = c(0, 100000)) ``` ]] .column[.content[ <img src="data:image/png;base64,#Modulo_3_Presentacion_files/figure-html/output_g3_12-1.png" width="100%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = base) + aes(x = NIVEL_ED) + aes(y = P21) + geom_boxplot() + aes(group = NIVEL_ED) + aes(fill = NIVEL_ED) + theme_minimal() + labs(x = "Máximo nivel educativo alcanzado") + labs(y = "Ingreso de la ocupación principal") + labs(title = "Boxplot del Ingreso de la Ocupación Principal por máximo nivel de estudios alcanzado") + labs(caption = "Fuente: Elaboración propia en base a EPH-INDEC") + scale_y_continuous(limits = c(0, 100000)) + * coord_flip() ``` ]] .column[.content[ <img src="data:image/png;base64,#Modulo_3_Presentacion_files/figure-html/output_g3_13-1.png" width="100%" /> ]] --- class: middle, center, inverse ## Gráficos de densidad ### Probemos con otro tipo de gráfico, que ayude a comparar mejor (que es nuestro objetivo) --- class: split-40 count: false .column[.content[ ```r *ggplot(data = base) ``` ]] .column[.content[ <img src="data:image/png;base64,#Modulo_3_Presentacion_files/figure-html/output_g4_1-1.png" width="100%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = base) + * aes(x = P21) ``` ]] .column[.content[ <img src="data:image/png;base64,#Modulo_3_Presentacion_files/figure-html/output_g4_2-1.png" width="100%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = base) + aes(x = P21) + * geom_density() ``` ]] .column[.content[ <img src="data:image/png;base64,#Modulo_3_Presentacion_files/figure-html/output_g4_3-1.png" width="100%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = base) + aes(x = P21) + geom_density() + * aes(group = NIVEL_ED) ``` ]] .column[.content[ <img src="data:image/png;base64,#Modulo_3_Presentacion_files/figure-html/output_g4_4-1.png" width="100%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = base) + aes(x = P21) + geom_density() + aes(group = NIVEL_ED) + * aes(color = NIVEL_ED) ``` ]] .column[.content[ <img src="data:image/png;base64,#Modulo_3_Presentacion_files/figure-html/output_g4_5-1.png" width="100%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = base) + aes(x = P21) + geom_density() + aes(group = NIVEL_ED) + aes(color = NIVEL_ED) + * theme_minimal() ``` ]] .column[.content[ <img src="data:image/png;base64,#Modulo_3_Presentacion_files/figure-html/output_g4_6-1.png" width="100%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = base) + aes(x = P21) + geom_density() + aes(group = NIVEL_ED) + aes(color = NIVEL_ED) + theme_minimal() + * labs(x = "Máximo nivel educativo alcanzado", * y = "Ingreso de la ocupación principal", * title = "Ingreso de la Ocupación Principal por máximo nivel de estudios alcanzado", * caption = "Fuente: Elaboración propia en base a EPH-INDEC") ``` ]] .column[.content[ <img src="data:image/png;base64,#Modulo_3_Presentacion_files/figure-html/output_g4_10-1.png" width="100%" /> ]] --- class: middle, center, inverse ## Gráficos de densidad ### Todavía falta, el gráfico no es claro y la información está muy amontonada. ¿Y si separamos los gráficos por categoría? --- class: split-40 count: false .column[.content[ ```r *ggplot(data = base) ``` ]] .column[.content[ <img src="data:image/png;base64,#Modulo_3_Presentacion_files/figure-html/output_g5_1-1.png" width="100%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = base) + * aes(x = P21) ``` ]] .column[.content[ <img src="data:image/png;base64,#Modulo_3_Presentacion_files/figure-html/output_g5_2-1.png" width="100%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = base) + aes(x = P21) + * geom_density() ``` ]] .column[.content[ <img src="data:image/png;base64,#Modulo_3_Presentacion_files/figure-html/output_g5_3-1.png" width="100%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = base) + aes(x = P21) + geom_density() + * aes(group = NIVEL_ED) ``` ]] .column[.content[ <img src="data:image/png;base64,#Modulo_3_Presentacion_files/figure-html/output_g5_4-1.png" width="100%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = base) + aes(x = P21) + geom_density() + aes(group = NIVEL_ED) + * aes(color = NIVEL_ED) ``` ]] .column[.content[ <img src="data:image/png;base64,#Modulo_3_Presentacion_files/figure-html/output_g5_5-1.png" width="100%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = base) + aes(x = P21) + geom_density() + aes(group = NIVEL_ED) + aes(color = NIVEL_ED) + * theme_minimal() ``` ]] .column[.content[ <img src="data:image/png;base64,#Modulo_3_Presentacion_files/figure-html/output_g5_6-1.png" width="100%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = base) + aes(x = P21) + geom_density() + aes(group = NIVEL_ED) + aes(color = NIVEL_ED) + theme_minimal() + * labs(x = "Máximo nivel educativo alcanzado", * y = "Ingreso de la ocupación principal", * title = "Ingreso de la Ocupación Principal por máximo nivel de estudios alcanzado", * caption = "Fuente: Elaboración propia en base a EPH-INDEC") ``` ]] .column[.content[ <img src="data:image/png;base64,#Modulo_3_Presentacion_files/figure-html/output_g5_10-1.png" width="100%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = base) + aes(x = P21) + geom_density() + aes(group = NIVEL_ED) + aes(color = NIVEL_ED) + theme_minimal() + labs(x = "Máximo nivel educativo alcanzado", y = "Ingreso de la ocupación principal", title = "Ingreso de la Ocupación Principal por máximo nivel de estudios alcanzado", caption = "Fuente: Elaboración propia en base a EPH-INDEC") + * facet_wrap(~ NIVEL_ED) ``` ]] .column[.content[ <img src="data:image/png;base64,#Modulo_3_Presentacion_files/figure-html/output_g5_11-1.png" width="100%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = base) + aes(x = P21) + geom_density() + aes(group = NIVEL_ED) + aes(color = NIVEL_ED) + theme_minimal() + labs(x = "Máximo nivel educativo alcanzado", y = "Ingreso de la ocupación principal", title = "Ingreso de la Ocupación Principal por máximo nivel de estudios alcanzado", caption = "Fuente: Elaboración propia en base a EPH-INDEC") + facet_wrap(~ NIVEL_ED) + * scale_x_continuous(limits = c(0, 100000)) ``` ]] .column[.content[ <img src="data:image/png;base64,#Modulo_3_Presentacion_files/figure-html/output_g5_12-1.png" width="100%" /> ]] --- class: middle, center, inverse ## Gráficos de Barras ### Ahora queremos conocer cómo se distribuye la población en función del máximo nivel educativo alcanzado --- - Observemos un poco más sobre la variable con las herramientas que conocemos ```r base %>% calculate_tabulates(x = "NIVEL_ED", add.totals = "row", add.percentage = "col", weights = "PONDERA") ``` ``` NIVEL_ED Freq Sin instruccion 1.0 Primaria incompleta 4.6 Primaria completa 13.1 Secundaria incompleta 16.1 Secundaria completa 27.6 Sup. incompleto 15.4 Sup. completo 22.2 Total 100.0 ``` --- ¿Y si la cruzamos por sexo? ```r base %>% calculate_tabulates(x = "NIVEL_ED", y = "CH04", add.totals = "row", add.percentage = "col", weights = "PONDERA") ``` ``` NIVEL_ED/CH04 1 2 Sin instruccion 0.0 2.1 Primaria incompleta 5.2 4.0 Primaria completa 16.8 8.5 Secundaria incompleta 17.9 13.9 Secundaria completa 27.0 28.4 Sup. incompleto 16.1 14.6 Sup. completo 17.0 28.6 Total 100.0 100.0 ``` --- Nuevamente, tenemos que editar la variable para poder trabajar con las etiquetas: ```r base <- base %>% mutate(CH04 = factor(CH04, levels = c(1, 2), labels = c("Varón", "Mujer"))) table(base$CH04) ``` ``` Varón Mujer 354 274 ``` --- Creamos el objeto `base_graf`, en donde asignamos el resultado del tabulado, con algunas modificaciones para trabajar más cómodxs en el gráfico. ```r base_graf <- base %>% group_by(CH04, NIVEL_ED) %>% summarise(cantidad = sum(PONDERA)) %>% mutate(porcentaje = cantidad / (sum(cantidad))* 100) %>% mutate(porcentaje = round(porcentaje, 1)) base_graf ``` ``` # A tibble: 13 x 4 # Groups: CH04 [2] CH04 NIVEL_ED cantidad porcentaje <fct> <fct> <int> <dbl> 1 Varón Primaria incompleta 8384 5.2 2 Varón Primaria completa 27058 16.8 3 Varón Secundaria incompleta 28882 17.9 4 Varón Secundaria completa 43604 27 5 Varón Sup. incompleto 25933 16.1 6 Varón Sup. completo 27381 17 7 Mujer Sin instruccion 2793 2.1 8 Mujer Primaria incompleta 5196 4 9 Mujer Primaria completa 11166 8.5 10 Mujer Secundaria incompleta 18279 13.9 11 Mujer Secundaria completa 37232 28.4 12 Mujer Sup. incompleto 19095 14.6 13 Mujer Sup. completo 37474 28.6 ``` --- class: split-40 count: false .column[.content[ ```r *ggplot(data = base_graf, * aes(x = NIVEL_ED, * y = porcentaje, * fill = CH04)) ``` ]] .column[.content[ <img src="data:image/png;base64,#Modulo_3_Presentacion_files/figure-html/output_g6_4-1.png" width="100%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = base_graf, aes(x = NIVEL_ED, y = porcentaje, fill = CH04)) + * geom_bar(color = "black", * position = "dodge", * stat = "identity") ``` ]] .column[.content[ <img src="data:image/png;base64,#Modulo_3_Presentacion_files/figure-html/output_g6_7-1.png" width="100%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = base_graf, aes(x = NIVEL_ED, y = porcentaje, fill = CH04)) + geom_bar(color = "black", position = "dodge", stat = "identity") + * scale_fill_manual(values = c("forestgreen", "#c51b8a")) ``` ]] .column[.content[ <img src="data:image/png;base64,#Modulo_3_Presentacion_files/figure-html/output_g6_8-1.png" width="100%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = base_graf, aes(x = NIVEL_ED, y = porcentaje, fill = CH04)) + geom_bar(color = "black", position = "dodge", stat = "identity") + scale_fill_manual(values = c("forestgreen", "#c51b8a")) + * theme_minimal() ``` ]] .column[.content[ <img src="data:image/png;base64,#Modulo_3_Presentacion_files/figure-html/output_g6_9-1.png" width="100%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = base_graf, aes(x = NIVEL_ED, y = porcentaje, fill = CH04)) + geom_bar(color = "black", position = "dodge", stat = "identity") + scale_fill_manual(values = c("forestgreen", "#c51b8a")) + theme_minimal() + * theme(axis.text.x = element_text(angle = 35, * vjust = 0.5)) ``` ]] .column[.content[ <img src="data:image/png;base64,#Modulo_3_Presentacion_files/figure-html/output_g6_11-1.png" width="100%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = base_graf, aes(x = NIVEL_ED, y = porcentaje, fill = CH04)) + geom_bar(color = "black", position = "dodge", stat = "identity") + scale_fill_manual(values = c("forestgreen", "#c51b8a")) + theme_minimal() + theme(axis.text.x = element_text(angle = 35, vjust = 0.5)) + * labs(title = "Distribución porcentual de la población \n según máximo nivel educativo alcanzado y sexo.", * subtitle = "Total aglomerados, base _podada_. Año 2016, trimestre 4.", * caption = "Fuente: EPH-INDEC", * fill = "Sexo") ``` ]] .column[.content[ <img src="data:image/png;base64,#Modulo_3_Presentacion_files/figure-html/output_g6_15-1.png" width="100%" /> ]] --- class: split-40 count: false .column[.content[ ```r ggplot(data = base_graf, aes(x = NIVEL_ED, y = porcentaje, fill = CH04)) + geom_bar(color = "black", position = "dodge", stat = "identity") + scale_fill_manual(values = c("forestgreen", "#c51b8a")) + theme_minimal() + theme(axis.text.x = element_text(angle = 35, vjust = 0.5)) + labs(title = "Distribución porcentual de la población \n según máximo nivel educativo alcanzado y sexo.", subtitle = "Total aglomerados, base _podada_. Año 2016, trimestre 4.", caption = "Fuente: EPH-INDEC", fill = "Sexo") + * geom_text(aes(label = porcentaje, group = CH04), * position = position_dodge(0.9), * vjust = -0.5) ``` ]] .column[.content[ <img src="data:image/png;base64,#Modulo_3_Presentacion_files/figure-html/output_g6_18-1.png" width="100%" /> ]]